<?php
	function f621($sql){ // to be refined
		//data handle instance
		//set request
		//define format
		//set format
		//define query string
		//process time
		//process fitler
		$dataHandle = new DataHandle();
		$dataHandle->setRequest("621");

		$action = getValue($_GET['action']);

		if ($action == "getItems"){
			$query = getQuery();
			//echo $query;
			print($dataHandle->printJSON($sql, $query));
		}
		else{
			$temp = array();
			$temp['error'] = "621: Bad request";
			print(json_encode($temp));
		}

		unset($dataHandle);
	}
	function getQuery(){

		$id = $_GET['id'];

		$queryString = "
			SELECT 
				substring(name_form, 10, len(name_form)-9) as 'name_form',
				type,
				description,
				name_ctrl,
				enabled
			from 
				usr_Groups_Rights
			where group_id = ".$id;

		$oderByFiled = getValue($_GET['sortItem']);
		$oderByValue = getValue($_GET['ascDesc']);

		if($oderByFiled !== "" and $oderByValue !== "")
			$queryString = $queryString." order by ".$oderByFiled." ".$oderByValue;
			//substring(name_form, 10, len(name_form)-9) as 'Form',
			//where name_form != 'CollectAllButtonsInApp' and 
			//and enabled = 'True'

		return $queryString;
	}
?>